package jjn.acwing.algorithm_basic.chapter1.big_number;

import java.util.*;

/**
 * @author Jiang Jining
 * @since 2023-09-17 19:20
 */
public class Acwing794 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        int b = scanner.nextInt();
        int length = a.length();
        List<Integer> nums = new ArrayList<>();
        for (int i = 0; i < length; i++) {
            nums.add(a.charAt(i) - '0');
        }
        Deque<Integer> deque = new ArrayDeque<>();
        int t = 0;
        for (Integer num : nums) {
            t = t * 10 + num;
            deque.offer(t / b);
            t = t % b;
        }
        while (deque.size() > 1 && Objects.equals(deque.peekFirst(), 0)) {
            deque.pollFirst();
        }
        while (!deque.isEmpty()) {
            System.out.print(deque.pollFirst());
        }
        System.out.println();
        System.out.println(t);
    }
}
